package produceAndConsum;

import java.util.LinkedList;

public class Main{
    public static Semaphore s=new Semaphore();

    public static int nextin=0,nextout=0;
    public static char buffer[]={'0','0','0','0','0'};

    public static void main(String[] args){
        //假设有四个生产者和四个消费者对4个缓冲区进行同步和互斥地访问
        new Thread(new Producer(),"一号生产者").start();
        new Thread(new Consumer(),"一号消费者").start();
        new Thread(new Producer(),"二号生产者").start();
        new Thread(new Consumer(),"二号消费者").start();
        new Thread(new Producer(),"三号生产者").start();
        new Thread(new Consumer(),"三号消费者").start();
        new Thread(new Producer(),"四号生产者").start();
        new Thread(new Consumer(),"四号消费者").start();
    }

}

class Semaphore{
    public int count=0,value=5;
    public int K=5;
    public int mutex=1,empty=5,full=0;//信号量
    LinkedList<Thread> processlist=new LinkedList();
    LinkedList<Thread> mutexlist=new LinkedList();
}
